#include"RuningQueue.hpp"

void* Consumer(void* arg)
{
  RuningQueue<int>* rq = (RuningQueue<int>*) arg;
  while(true)
  {
    int data = 0;
    rq->Get(data);    
    std::cout<<"Consumer done:"<< data <<std::endl;
    sleep(1);
  }
}

void* Product(void* arg)
{
  RuningQueue<int>* rq = (RuningQueue<int>*) arg;
  while(true)
  {
    int data = rand() % 10 + 1;
    rq->Put(data);
    std::cout<<"Product done:"<<data<<std::endl;
  }
}

int main()
{
 pthread_t c,p;
RuningQueue<int>*rq = new RuningQueue<int>;
 pthread_create(&c,nullptr,Consumer,rq);
 pthread_create(&p,nullptr,Product,rq);

 pthread_join(c,nullptr);
 pthread_join(p,nullptr);
 delete rq;
  return 0;
}
